// 开发环境配置
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const BaseWebpackConfig = require('./webpack.base.config');
const { merge } = require('webpack-merge');

const config = merge(BaseWebpackConfig,  {
    entry: {
        index: './src/index.js',
    },
    output: {
        filename: "[name].[hash:8].js",
        path: path.resolve(__dirname, 'dist'),
        chunkFilename: '[name].js',
    },
    devServer: {
        contentBase: './dist'
    },
    plugins: [
        new HtmlWebpackPlugin({
            inject: 'body',
            filename: 'index.html',
            template: 'index.html',
            chunks:['index'],
            scriptLoading: 'defer',
            hash: true,
            minify: {
                collapseWhitespace: true,
                removeComments: true,
                removeEmptyElements: false
            }
        }),
    ]
});
module.exports = config;
